axios.defaults.baseURL='http://www.itcbc.com:8080';


axios.interceptors.response.use(function (response) {
    // 对响应数据做点什么

    if(response.data.status === 1){
        layer.msg(response.data.message);
    }
    return response;

  }, function (error) {
    // 对响应错误做点什么

    // 响应状态码大于等于400执行这个函数

    // error.response为返回结果
    // error.response.data 为返回的参数

    if(error.response.data.status === 1){
        layer.msg(error.response.data.message);   
    }

    if(error.response.data.status ===1 &&error.response.data.message=='身份认证失败'){
        localStorage.removeItem('token');
    }


    return Promise.reject(error);
  });


axios.interceptors.request.use(config => {
// Do something before request is sent
if(config.url.includes('/my/')){
    config.headers.Authorization = localStorage.getItem('token')
    // console.log(localStorage.getItem('token'))
}

return config;
},error => {
// Do something with request error
return Promise.reject(error);
});






//   Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjM3MDksImlhdCI6MTYzNTA1OTE4NywiZXhwIjoxNjM1MDY2Mzg3fQ.JKVoMhbQ4sQhZ0Gox-MuwEeIkWbbWhrxuvaSjLXQhd4


